package com.xl.imports;

import com.xl.beans.OtherBean2;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ImportSelector;
import org.springframework.core.type.AnnotationMetadata;

import java.util.Map;

public class MyImportSelector implements ImportSelector {
    @Override
    public String[] selectImports(AnnotationMetadata annotationMetadata) {
        //参数annotationMetadata叫做注解媒体数组，该对象内部封装是使用了@Import注解的类上的其他注解的元数据信息
        Map<String, Object> map = annotationMetadata.getAnnotationAttributes(MapperScan.class.getName());
        map.forEach((k, v) -> System.out.println(k + "======" + v));
        //返回的数组封装是需要被注册到spring容器的bean的全限定名
        return new String[]{OtherBean2.class.getName()};
    }
}
